using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing.Design;
using System.Collections;

using System.Windows.Forms;
using System.Drawing;
using Camalon.Drawing;

namespace Camalon.Drawing.Design
{
	/// <summary>
	/// Summary description for ShapeContainerDesigner.
	/// </summary>
	public class ShapeContainerDesigner:ShapeDesigner
	{
		public ShapeContainerDesigner()
		{
			//
			// TODO: Add constructor logic here
			//
		}


		public ShapeContainer ShapeContainer
		{
			get{ return this.Component as ShapeContainer;}

		}



		private bool IsRootContainer
		{

			get
			{

				ShapeContainerRootDesignerBase rootDesigner = base.ShapeContainerRootDesigner;
				if( rootDesigner == null) return false;
				return rootDesigner.ShapeContainer == this.ShapeContainer;
				
			}
		}

		#region Properties
//		[Browsable( false)]
//		[EditorBrowsable( EditorBrowsableState.Never )]
//		[DesignerSerializationVisibility( DesignerSerializationVisibility.Hidden)]
//		[Category("Transformation")]
//		public Size ScalingResizeBase
//		{
//			get{ return this.ShapeContainer.ScalingResizeBase;}
//		}
//
//
//		[Browsable( false)]
//		[EditorBrowsable( EditorBrowsableState.Never )]
//		[DesignerSerializationVisibility( DesignerSerializationVisibility.Hidden)]
//		[Category("Transformation")]
//		public bool ScalingResize
//		{
//			get{ return false;}
//		}


		[Browsable( false)]
		[EditorBrowsable( EditorBrowsableState.Never )]
		[DesignerSerializationVisibility( DesignerSerializationVisibility.Hidden)]
		[Category("Layout")]
		public Shape ContainerBaseShape
		{
			get{ return this.ShapeContainer.ContainerBaseShape;}
		}

		[Browsable(false)]
		[Category("Shapes")]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
		public ShapeCollection Shapes
		{
			get
			{
				return this.ShapeContainer.Shapes;
			}
		}

		#endregion Properties

		protected override void PreFilterProperties(IDictionary properties)
		{
			base.PreFilterProperties (properties);

			properties["Shapes"] = TypeDescriptor.CreateProperty(
				typeof(ShapeContainerDesigner), 
				"Shapes", 
				typeof(ShapeCollection));
			
			if(!this.IsRootContainer )
			{
				properties["ContainerBaseShape"] = TypeDescriptor.CreateProperty(
					typeof(ShapeContainerDesigner), 
					"ContainerBaseShape", 
					typeof(Shape) );
			}

			if( this.IsRootContainer )
			{

				#region override base designer properties

				properties["Scale"] = TypeDescriptor.CreateProperty(
					typeof(ShapeContainerDesigner), 
					"Scale", 
					typeof(Scale), 
					new Attribute[]{BrowsableAttribute.No });

				properties["Shear"] = TypeDescriptor.CreateProperty(
					typeof(ShapeContainerDesigner), 
					"Shear", 
					typeof(Shear),
					new Attribute[]{BrowsableAttribute.No });
	
				properties["Warp"] = TypeDescriptor.CreateProperty(
					typeof(ShapeContainerDesigner), 
					"Warp", 
					typeof(Warp),
					new Attribute[]{BrowsableAttribute.No });

				properties["Rotation"] = TypeDescriptor.CreateProperty(
					typeof(ShapeContainerDesigner), 
					"Rotation", 
					typeof(int),
					new Attribute[]{BrowsableAttribute.No });

				properties["Outline"] = TypeDescriptor.CreateProperty(
					typeof(ShapeContainerDesigner), 
					"Outline", 
					typeof(Outline),
					new Attribute[]{BrowsableAttribute.No });


				#endregion override base designer properties

//				properties["ScalingResizeBase"] = TypeDescriptor.CreateProperty(
//					typeof(ShapeContainerDesigner), 
//					"ScalingResizeBase", 
//					typeof(Size));
//
//				properties["ScalingResize"] = TypeDescriptor.CreateProperty(
//					typeof(ShapeContainerDesigner), 
//					"ScalingResize", 
//					typeof(bool));

			}
		}
	}
}
